package com.spsoft.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spsoft.system.entity.NvatOutInvoiceDetails;
import com.spsoft.system.entity.NvatOutInvoiceItems;
import com.spsoft.system.entity.NvatRevmapinvoitems;
import com.spsoft.system.mapper.NvatOutInvoiceDetailsMapper;
import com.spsoft.system.mapper.NvatOutInvoiceItemsMapper;
import com.spsoft.system.mapper.NvatRevmapinvoitemsMapper;
import com.spsoft.system.model.vo.official.InvoiceInfoVO;
import com.spsoft.system.service.NvatOutinvoicedetailsService;
import com.spsoft.system.service.NvatRevmapinvoitemsService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 销项发票明细信息 服务实现类
 * </p>
 *
 * @author dingchengyun
 * @since 2024-03-11
 */
@RequiredArgsConstructor
@Service
public class NvatOutinvoicedetailsServiceImpl extends ServiceImpl<NvatOutInvoiceDetailsMapper, NvatOutInvoiceDetails> implements NvatOutinvoicedetailsService {

    private final NvatRevmapinvoitemsService nvatRevmapinvoitemsService;

    private final NvatOutInvoiceItemsMapper nvatOutInvoiceItemsMapper;

    @Override
    public List<InvoiceInfoVO> queryInvoiceBYRdids(List<Long> rdidList) {
        return baseMapper.queryInvoiceBYRdids(rdidList);
    }

    /**
     * 删除待开发票的发票数据、发票明细数据、关联关系表数据
     *
     * @param oidIds
     * @return
     */
//    public void deleteDetailsItemRevByOidIds(List<Long> oidIds) {
//        // 删除发票信息表
//        LambdaQueryWrapper<NvatOutInvoiceDetails> wapper = new LambdaQueryWrapper<>();
//        wapper.in(NvatOutInvoiceDetails::getOidid, oidIds);
//        super.baseMapper.delete(wapper);
//        // 删除发票明细表
//        LambdaQueryWrapper<NvatOutInvoiceItems> itemWapper = new LambdaQueryWrapper<>();
//        itemWapper.in(NvatOutInvoiceItems::getOidid, oidIds);
//        nvatOutInvoiceItemsMapper.delete(itemWapper);
//        // 删除关联关系表
//        nvatRevmapinvoitemsService.deleteDetailsItemRevByOidIds(oidIds);
//
//    }

    @Override
    public boolean insertDetail(NvatOutInvoiceDetails details) {
        return super.save(details);
    }
}
